// This function injects a resource file from the extension into the <head> of a page
function injectFile(filename)
{
	// Create the script block setting src to injected js file 
	var s = document.createElement('script');
	s.setAttribute('src',chrome.extension.getURL(filename)); 
	s.setAttribute('type', 'text/javascript');
	document.body.appendChild(s);  
}

if (typeof(GM_getValue) == 'undefined')
{
	// GM_get/setValue based on pup's cookie code again
	var GM_getValue = function(name, defaultValue) 
	{
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) 
		{
			begin = dc.indexOf(prefix);
			if (begin != 0) return defaultValue;
		}
		else
		{
			begin += 2;
		}
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		{
			end = dc.length;
		}
		return unescape(dc.substring(begin + prefix.length, end));
	};
}

/*
	// confirm_unload was causing issues for users and basically useless for detecting the stupid malware redirects

// Load files that can be executed before the page is rendered
if (window == window.top)
{
	// confirm_unload
	if (GM_getValue('confirm_unload', 'true') == 'true') 
	{ 
		window.onbeforeunload = function() {
			return "Are you sure you want to leave this page? If you're seeing this message and didn't click on a link, that anti-virus ad may be attempting to hijack your machine.";
		} 
	}
}

*/